# $Id: PKGBUILD 89911 2013-05-05 14:49:19Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=mediawiki
pkgver=1.20.5
pkgrel=1
pkgdesc="MediaWiki engine"
arch=('any')
url="http://www.mediawiki.org/wiki/MediaWiki"
# + http://www.mediawiki.org/wiki/Extension:Math
license=("GPL")
depends=('php')
optdepends=('texvc: for math rendering'
	    'python2'
	    'pcre: for regular expressions support'
	    'php-intl: to handle Unicode normalization'
	    'php-mysql: for MySQL database support'
	    'php-pgsql: for PostgreSQL database support'
	    'php-sqlite: for sqlite database support'
	    'php-apc: for cache support'
	    'php-xcache: for cache support'
	    'memcached: for cache support'
	    'php-gd: for thumbnails rendering'
	    'imagemagick: for thumbnails rendering'
	    'sendmail: for meail sending')
backup=(etc/webapps/mediawiki/.htaccess)
install=mediawiki.install
options=(!strip)
source=(http://download.wikimedia.org/mediawiki/1.20/mediawiki-$pkgver.tar.gz
	mediawiki-math-1.20.tar.gz::https://nodeload.github.com/wikimedia/mediawiki-extensions-Math/legacy.tar.gz/REL1_20
	apache.example.conf)
md5sums=('4676e26cde186c8aa31fb3e46851afad'
         'ee8fceb0a86f2972409104767406591c'
         '99c25f04d4093f3333db1be7624fe4e7')

package() {
  cd $srcdir
  install -vdm0755 $pkgdir/usr/share/webapps
  install -vdm0755 $pkgdir/etc/webapps/mediawiki
  cp -a $pkgname-$pkgver $pkgdir/usr/share/webapps/mediawiki
  cp -a wikimedia-mediawiki-extensions-Math-* $pkgdir/usr/share/webapps/mediawiki/extensions/Math
  ln -s /usr/bin/texvc $pkgdir/usr/share/webapps/mediawiki/extensions/Math/math/texvc
  echo "deny from all" >> $pkgdir/etc/webapps/mediawiki/.htaccess
  ln -sf /etc/webapps/mediawiki/.htaccess $pkgdir/usr/share/webapps/mediawiki/.htaccess
  install -vDm0644 $srcdir/apache.example.conf $pkgdir/etc/webapps/mediawiki/apache.example.conf

  # move cache and images to /var
  install -vdm0755 -o http -g http $pkgdir/var/cache/mediawiki
  install -vdm0755 -o http -g http $pkgdir/var/lib/mediawiki

  cd $pkgdir/usr/share/webapps/mediawiki

  mv cache/.htaccess $pkgdir/var/cache/mediawiki/
  rmdir cache
  ln -sf /var/cache/mediawiki cache

  mv images/* $pkgdir/var/lib/mediawiki/
  mv images/.htaccess $pkgdir/var/lib/mediawiki/
  rmdir images
  ln -sf /var/lib/mediawiki images
}
